﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WCFMINERP.Contracts.DataContracts
{
    public class UploadInfo 
    {
         
        public string ShopName { get; set; }//商户名字
        public string ZipName { get; set; }//包名
        public DateTime CreateTime { get; set; }//创建时间
        public decimal Guage { get; set; }//进度
        public long FileLength { get; set; }//文件大小
        
        public int Status { get; set; }//等待上传，正在上传，上传完毕
        public decimal LastGuage { set; get; }//上一次进度
        public DateTime LastTime { get; set; }//上一次更改时间
        public DateTime SaveTime { get; set; }//上一次更改时间
        public string Speed {
            get {
                if (Guage == 0 || SaveTime < Convert.ToDateTime("2000-01-01"))
                {
                    return "0k/s";
                }
                if (Convert.ToDecimal((SaveTime - LastTime).TotalSeconds) == 0)
                {
                    return "0k/s";
                }
                else
                {
                    decimal Sd = (Guage - LastGuage) / Convert.ToDecimal((SaveTime - LastTime).TotalSeconds);
                     if (Sd <= 1024)
                     {
                         return Sd + "B/s";
                     }
                     else if (Sd >= 1024 && Sd < 1048576)
                     {
                         return (Sd/1024).ToString("0.00") + "MB/s";
                     }
                     
                     else
                     {
                         return (Sd / 1024 / 1024).ToString("0.00") + "GB/s";
                     }
                     

                }
        } 
        }//速度
        //进度
        public string GuagaPresent { get {
            if (FileLength == 0)
            {
                return "0";
            }
            else
            {
                return (Guage / FileLength*100).ToString("0.00")+"%";
            }
        }
        }
        public UploadInfo()
        {
            LastTime = SaveTime = Convert.ToDateTime("2000-01-01");
        }

        public DateTime CompleteTime { get; set; }

        public string DisplayLength
        {
            get { return ((decimal)FileLength / 1024 / 1024).ToString()+"MB"; }
        }
    }


    public class UploadQueueInfo
    {
        public int ShopId{get;set;}////商户ID

        public int orderbagid { get; set; }//订单ID

        public string Remark { get; set; }//备注
        public string MachineName{get;set;}//电脑名字
        public string ShoptempPath { get; set; }//文件路径

        public string ShopName { get; set; }//商户名字
        public string ZipName { get; set; }//包名
        public DateTime CreateTime { get; set; }//创建时间
        public decimal Guage { get; set; }//进度
        public long FileLength { get; set; }//文件大小

        public int Status { get; set; }//等待上传，正在上传，上传完毕
        public decimal LastGuage { set; get; }//上一次进度
        public DateTime LastTime { get; set; }//上一次更改时间
        public DateTime SaveTime { get; set; }//上一次更改时间
        public string Speed
        {
            get
            {
                if (Guage == 0 || SaveTime < Convert.ToDateTime("2000-01-01"))
                {
                    return "0k/s";
                }
                if (Convert.ToDecimal((SaveTime - LastTime).TotalSeconds) == 0)
                {
                    return "0k/s";
                }
                else
                {
                    decimal Sd = (Guage - LastGuage) / Convert.ToDecimal((SaveTime - LastTime).TotalSeconds);
                    if (Sd <= 1024)
                    {
                        return Sd + "B/s";
                    }
                    else if (Sd >= 1024 && Sd < 1048576)
                    {
                        return (Sd / 1024).ToString("0.00") + "MB/s";
                    }

                    else
                    {
                        return (Sd / 1024 / 1024).ToString("0.00") + "GB/s";
                    }


                }
            }
        }//速度
        //进度
        public string GuagaPresent
        {
            get
            {
                if (FileLength == 0)
                {
                    return "0";
                }
                else
                {
                    return (Guage / FileLength * 100).ToString("0.00") + "%";
                }
            }
        }
       
        public DateTime CompleteTime { get; set; }

        public string DisplayLength
        {
            get { return ((decimal)FileLength / 1024 / 1024).ToString() + "MB"; }
        }
    }
}
